<% var obj = {pageTitle:"注册/绑定"} %>
{{include "../header.html" obj}}
<div class=" container">
    {{include "../pageHeader.html" obj}}
    <div class="col-md-4 col-md-offset-4">
        <ul class="nav nav-tabs nav-justified">
            <li class="active"><a href="#paneRegister" data-toggle="tab">注册账号</a></li>
            <li><a href="#paneLogin" data-toggle="tab">已有账号</a></li>
        </ul>
        <div class="tab-content" style="margin-top:20px">
            <div class="tab-pane fade in active" id="paneRegister">
                <form class=" form-horizontal" method="POST" action="/admin/register" enctype="application/x-www-form-urlencoded">
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-user"></span>
                            </div>
                            <input type="text" class=" form-control" data-tip="账号" name="userName">
                        </div>
                    </div>
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-lock"></span>
                            </div>
                            <input type="password" class=" form-control" data-tip="密码" name="userPwd">
                        </div>
                    </div>
                    <input type="hidden" value="{{model.openid}}" name="openid">
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-asterisk"></span>
                            </div>
                            <input type="password" class=" form-control" data-tip="确认密码" id="conPwd">
                        </div>
                    </div>
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-envelope"></span>
                            </div>
                            <input type="email" class=" form-control" data-tip="邮件" id="userEmail">
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default">获取验证码
                                </button>
                            </div>
                        </div>
                    </div>
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-asterisk"></span>
                            </div>
                            <input type="text" class=" form-control" data-tip="验证码" name="checkCode">
                        </div>
                    </div>
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-th-list"></span>
                            </div>
                            <select name="userType" id="" class=" form-control">
                                <option value="">--请选择用户类型--</option>
                                <option value="超级管理员">超级管理员</option>
                                <option value="宿舍管理员">宿舍管理员</option>
                                <option value="学生">学生</option>
                            </select>
                        </div>
                    </div>
                    <div class=" form-group">
                        <button type="submit" class=" btn btn-primary btn-block btn-submit-loading" disabled>注册</button>
                    </div>
                </form>
            </div>
            <div class="tab-pane" id="paneLogin">
                <form class=" form-horizontal" method="POST" action="/admin/bindOldUser" enctype="application/x-www-form-urlencoded">
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-user"></span>
                            </div>
                            <input type="text" class=" form-control" data-tip="账号" name="userName">
                        </div>
                    </div>
                    <div class=" form-group">
                        <div class=" input-group">
                            <div class=" input-group-addon">
                                <span class=" glyphicon glyphicon-lock"></span>
                            </div>
                            <input type="password" class=" form-control" data-tip="密码" name="userPwd">
                        </div>
                    </div>
                    <input type="hidden" value="{{model.openid}}" name="openid">
                    <div class=" form-group">
                        <button type="submit" class=" btn btn-primary btn-block btn-submit-loading">绑定</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $(".form-control").inputTips();
        $(".btn-default").click(function (e) {
            if ($("#userEmail").val() == "") {
                layer.msg("邮箱不能为空");
            }
            else {
                var userEmail = $("#userEmail").val();
                $.get("/admin/getCheckCode?userEmail=" + userEmail,
                    function (data, textStatus, jqXHR) {
                        if (data.status == "success") {
                            layer.msg(data.msg);
                        }
                        else {
                            layer.msg(data.msg);
                        }
                    }
                );
            }
        });
        $("#conPwd").blur(function (e) {
            var text1 = $("[name='userPwd']").val();
            var text2 = $(this).val();
            if (text1 == "") {
                layer.msg("请输入密码");
            }
            else if (text1 != text2) {
                $("#paneRegister [type='submit']").prop("disabled", true);
                layer.msg("两次密码不一致");
            }
            else {
                $("#paneRegister [type='submit']").prop("disabled", false);
            }
        })
    })
</script>
{{include "../footer.html"}}